package commands

import aqv.User;

@grails.validation.Validateable
class LoginCommand {


	String login
	String password
	private u
	
	
	User getUser() {
		if(!u && login) {
			u = User.findByLogin(login)
		}
		return u
	}
	
	
	static constraints = {
		login blank:false, validator:{ val, obj ->
		if(!obj.user)
			return "error.user.not.found"
		}
		password blank:false, validator:{ val, obj ->
		if(obj.user && obj.user.password != val)
			return "error.user.password.invalid"
		}
	}

	
	
}
